/*******************************************************************\
| AreaLight.h
|
| CREATED:		14.6.2009
| DESCRIPTION:
| 
| Area light implementation
\********************************************************************/
#ifndef AREALIGHT_H
#define AREALIGHT_H

#include "Light.h"

namespace PhotonMapping
{

//*****************************************************************************
// class overview:
//   Area light class implementation
//-----------------------------------------------------------------------------
class AreaLight : public ILight
{
	public:
		AreaLight(const Math::Vector3& p_P0, const Math::Vector3& p_P1, const Math::Vector3& p_P2, const Math::Vector3& p_P3, const Color& p_Color, const float p_Intensity);

		// create a projection map for the given scene to optimize photon tracing
		virtual void CreateProjectionMap(const ScenePtr p_Ptr);

		// returns a light ray for photon tracing
		virtual const Math::Ray SampleLightRay(float p_U1, float p_U2);

		// returns the lights maximum emitted flux
		virtual const Color GetMaxFlux();

	private:
		// area light positions
		Math::Vector3 m_P0, m_P1, m_P2, m_P3;
		
		// area light normal
		Math::Vector3 m_Normal;

		// area light area
		float m_Area;

		// flag whether a projection map is used or not
		bool m_UsePM;
};

}

#endif // AREALIGHT_H
